package hn.cch.framework.akka;

import akka.actor.UntypedAbstractActor;
import akka.event.Logging;
import akka.event.LoggingAdapter;

public class FunctionActor extends UntypedAbstractActor {

    private LoggingAdapter log = Logging.getLogger(getContext().getSystem(), this);

    @Override
    public void onReceive(Object message) throws Throwable {
        log.info("onReceive:{}", message);
        if (message instanceof Request) {
            log.info("request:{}", message);
            Request request = (Request) message;
            getSender().tell(request.getMessage(), getSelf());
        } else {
            unhandled(message);
        }
    }
}
